package day5.demo2_顺序执行;

public class JoinTest {
 // 1.现在有T1、T2、T3三个线程，你怎样保证T2在T1执行完后执行，T3在T2执行完后执行
     public static void main(String[] args) throws Exception{
         final Thread t1 = new Thread(new Runnable() {
             @Override
             public void run() {
                 System.out.println("1.项目需求分析");
             }
         });
         final Thread t2 = new Thread(new Runnable() {
             @Override
             public void run() {
                 try {
                     t1.join();// 引用t1线程，等待t1线程执行完
                 } catch (Exception e) {}
                 System.out.println("2.项目方案设计");
                 int[]arr = new int[]{};

             }
         });
         Thread t3 = new Thread(() -> {
             try {
                 t2.join();// 引用t2线程，等待t2线程执行完
             } catch (Exception e) {}
             System.out.println("3.项目编码");
         });
         t1.start();
         Thread.sleep(1000);
         t2.start();
         Thread.sleep(1000);
         t3.start();//这里三个线程的启动顺序可以任意，大家可以试下！


     }
}